/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jdbc.dataAccess;

import com.jdbc.dataAccess.Oracle.ParameterDirection;
import java.util.ArrayList;
import java.util.List;

/******************************************************************************
 * 
 * @autor   robert.baron
 * @since       05-abr-2013
 * 
 *******************************************************************************/
public class DBProcedure {
      
      private String procedureName;
      private List<DBParameters> parameters;
      
      public DBProcedure(String procedureName){
            this.procedureName = procedureName;
            this.parameters = new ArrayList<DBParameters>();
      }

      public String getProcedureName() {
            return procedureName;
      }

      public void setProcedureName(String procedureName) {
            this.procedureName = procedureName;
      }
      
      public void addInParameter(String name,Object value,int type){
            
            if (name == null)  throw new NullPointerException("Parameter name  is null");
            
            DBParameters dbParameter = new DBParameters();
            
            dbParameter.setName(name);
            dbParameter.setValue(value);
            dbParameter.setType(type);
            dbParameter.setDirection(ParameterDirection.IN);
            
            parameters.add(dbParameter);
      }
      public void addOutParameter(String name,Object value,int type){
            
            if (name == null)  throw new NullPointerException("Parameter name  is null");
            
            DBParameters dbParameter = new DBParameters();
            
            dbParameter.setName(name);
            dbParameter.setValue(value);
            dbParameter.setType(type);
            dbParameter.setDirection(ParameterDirection.OUT);
            
            parameters.add(dbParameter);
      }
      
      public void addParameter(DBParameters dbParameter){
            
            if (dbParameter == null)  throw new NullPointerException("Parameter dbParameter  is null");            
            parameters.add(dbParameter);
      }
      
      public void addParameter(String name,Object value,int type,int direction){
            
            if (name == null)  throw new NullPointerException("Parameter name  is null");
            
            DBParameters dbParameter = new DBParameters();
            
            dbParameter.setName(name);
            dbParameter.setValue(value);
            dbParameter.setType(type);
            dbParameter.setDirection(direction);
            
            parameters.add(dbParameter);
      }
      
      public void setParameters(List<DBParameters> parameters){
            if (parameters == null)  throw new NullPointerException("Parameter list  is null");
            this.parameters = parameters;
      }
}
